package cn.josh.action;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import cn.josh.bean.Ec_order;
import cn.josh.service.Ec_orderService;
import cn.josh.servicelmpl.Ec_orderServiceImpl;

@WebServlet("/OrderDeleteServlet")
public class OrderDeleteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		//得到用户id
		HttpSession session = request.getSession();
		String userId = (String)session.getAttribute("userId");
		System.out.println("OrderDeleteServlet---userId:" + userId);
				
		//得到订单id
		String orderId = (String)request.getParameter("orderId");
		System.out.println("商品id是：" + orderId);
		
		//将数据封装
		Ec_order order = new Ec_order();
		order.setOrderId(orderId);
		order.setUserId(userId);
		
		//调用数据库服务
		Ec_orderService ec_os = new Ec_orderServiceImpl();
		ec_os.deleteOrder(order);
		
		response.sendRedirect("/ShoppingWebsite/OrderReadServlet");

	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
